public class Test4 {
    static volatile int isQuit = 0 ;
    public static void main(String[] args) {
         Thread t1 = new Thread(()->{
             while (isQuit == 0){

             }
             System.out.println("t1停止");
         });
         Thread t2 = new Thread(()->{
             System.out.println("3秒后t2把isQuit改成1");
             try {
                 Thread.sleep(3000);
             } catch (InterruptedException e) {
                 throw new RuntimeException(e);
             }
             isQuit = 1 ;
             System.out.println("isQuit=1");
         });
         t1.start();
         t2.start();

    }
}
